#include"Dlish.h"
#include<stdio.h>
#include<stdlib.h>

struct node{
    int data;
    struct list_head list;  //标准链表
};

struct node* init_list(void){  // 初始化链表
    struct node* head = malloc(sizeof(struct node));
    if(head != NULL)
        INIT_LIST_HEAD(&head->list);
    return head;
}

struct node* new_node(int data){  //新建节点
    struct node* new = malloc(sizeof(struct node));
    if(new != NULL){
        new->data = data;
        INIT_LIST_HEAD(&new->list);
    }
    return new;
}

int main(int argc, char const *argv[])
{
    struct node* head = init_list();
    int num;
    
    scanf("%d", &num);
    for(int i = 1; i <= num; i++){
        list_add_tail(&new_node(i)->list, &head->list);
    }
    struct list_head *pos;
    list_for_each(pos, &head->list){
        struct node *p = list_entry(pos, struct node, list);
        printf("%d\t", p->data);
    }
    printf("\n");
    return 0;
}
